<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        width: 400px;
        height: 400px;
        background-color: yellowgreen;
        position: relative;
      }

      #con {
        width: 100px;
        height: 100px;
        background-color: pink;
        position: absolute;
        left: 100px;
        top: 100px;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <div id="con"></div>
    </div>
    <script>
      const oBox = document.getElementById("box");
      const oCon = document.getElementById("con");

      oBox.onclick = function (e) {
        console.log(e.offsetX);
      };
    </script>
  </body>
</html>
